# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $ app-text/ghostdpl/ghostdpl-8.71,v 1.2 2012/10/17 18:35:00 itspec.ru Exp $

EAPI=3

inherit eutils

DESCRIPTION="GhostPCL, GhostXPS, Ghostscript and GhostPDF Interpreters"
HOMEPAGE="http://www.artifex.com/downloads/"
SRC_URI="http://downloads.ghostscript.com/public/ghostpdl-${PV}.tar.bz2"

LICENSE="GPLv2"

RESTRICT="mirror"

SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="pcl xps svg ls tools debug"

DEPEND=""

RDEPEND="${DEPEND}"

src_compile() {
    local BUILD=""

    if use debug; then
        BUILD="debug"
    else
        BUILD="product"
    fi

    if use pcl; then
        emake -j1 DESTDIR="${D}" -C main -f pcl6_gcc.mak pdl-${BUILD} || die "compile failure"
    fi

    if use xps; then
        emake -j1 DESTDIR="${D}" -C xps -f xps_gcc.mak pdl-${BUILD} || die "compile failure"
    fi

    if use svg; then
        emake -j1 DESTDIR="${D}" -C svg -f svg_gcc.mak pdl-${BUILD} || die "compile failure"
    fi

    if use ls; then
        emake -j1 DESTDIR="${D}" -C language_switch -f pspcl6_gcc.mak pdl-${BUILD} || die "compile failure"
    fi
}

src_install() {
    if use pcl; then
        dobin "${S}/main/obj/pcl6" || die "pcl6 install failed"
    fi

    if use xps; then
        dobin "${S}/xps/obj/gxps" || die "gxps install failed"
    fi

    if use svg; then
        dobin "${S}/svg/obj/gsvg" || die "gsvg install failed"
    fi

    if use ls; then
        dobin "${S}/language_switch/obj/pspcl6" || die "pspcl6 install failed"
    fi

    if use tools; then
        dobin "${S}/tools/pcl2pdf" || die "pcl2pdf install failed"
        dobin "${S}/tools/pcl2pdfwr" || die "pcl2pdfwr install failed"
    fi
}
